package com.wsoft.hr.pm.service.impl;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wsoft.hr.pm.entity.HrPmGradeMemberCycleEntity;
import com.wsoft.hr.pm.manager.HrPmGradeMemberCycleManager;
import com.wsoft.hr.pm.mapper.HrPmGradeMemberCycleMapper;
import com.wsoft.hr.pm.query.grade.member.cycle.HrPmGradeMemberCycleInsertQuery;
import com.wsoft.hr.pm.query.grade.member.cycle.HrPmGradeMemberCycleListQuery;
import com.wsoft.hr.pm.query.grade.member.cycle.HrPmGradeMemberCycleUpdateQuery;
import com.wsoft.hr.pm.service.IHrPmGradeMemberCycleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Z001
 * @Date 2025-03-01 08:35:23
 */
@Service
public class HrPmGradeMemberCycleServiceImpl extends ServiceImpl<HrPmGradeMemberCycleMapper, HrPmGradeMemberCycleEntity> implements IHrPmGradeMemberCycleService{

    @Resource
    private HrPmGradeMemberCycleManager hrPmGradeMemberCycleManager;

    /**
     * 评级人员周期表-分页查询
     * @param query
     * @return PageInfo
     */
    @Override
    public PageInfo<HrPmGradeMemberCycleEntity> listHrPmGradeMemberCycle(HrPmGradeMemberCycleListQuery query) {
        PageHelper.startPage(query.getPageNum(), query.getPageSize());
        List<HrPmGradeMemberCycleEntity> list = hrPmGradeMemberCycleManager.list(query);
        return PageInfo.of(list);
    }

    /**
     * 评级人员周期表-获取详情
     * @param id
     * @return
     */
    @Override
    public  HrPmGradeMemberCycleEntity getInfo(Long id) {
        return hrPmGradeMemberCycleManager.getById(id);
    }

    /**
     * 新增-评级人员周期表
     * @param query
     * @return
     */
    @Override
    public boolean insertHrPmGradeMemberCycle(HrPmGradeMemberCycleInsertQuery query) {
        return hrPmGradeMemberCycleManager.save(Convert.convert(HrPmGradeMemberCycleEntity.class, query));
    }

    /**
     *  更新-评级人员周期表
     *
     * @param query
     * @return
     */
    @Override
    public boolean updateHrPmGradeMemberCycle(HrPmGradeMemberCycleUpdateQuery query) {
        return hrPmGradeMemberCycleManager.updateById(Convert.convert(HrPmGradeMemberCycleEntity.class, query));
    }

    /**
     * 删除-评级人员周期表
     * @param id
     * @return
     */
    @Override
    public boolean delete(Long id) {
        return hrPmGradeMemberCycleManager.removeById(id);
    }
}
